package com.wss.common.utils;

import com.wss.common.base.BaseApplication;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;
import ohos.utils.net.Uri;

/**
 * description: 拨打电话工具类
 *
 * @author 杨伟-tony
 * create by 2020/5/22 11:26
 */
public class PhoneUtils {
    /**
     * 拨打电话
     * ps：调起拨号盘
     *
     * @param phoneNum 电话号码
     */
    public static void callPhoneWaitFor(String phoneNum) {

        Intent intent = new Intent();
        Operation operation = new Intent.OperationBuilder()
                .withUri(Uri.parse("tel:" + phoneNum))
                .withAction("ohos.intent.action.DIAL")
                .withFlags(Intent.FLAG_NOT_OHOS_COMPONENT)
                .build();
        intent.setOperation(operation);
        BaseApplication.i().startAbility(intent, 0);
    }

    /**
     * 拨打电话
     * 吊起拨号盘 直接拨打电话
     *
     * @param phoneNum 电话号码
     */
    public static void callPhoneDirect(String phoneNum) {

        Intent intent = new Intent();
        Operation operation = new Intent.OperationBuilder()
                .withUri(Uri.parse("tel:" + phoneNum))
                .withAction("ohos.intent.action.CALL")
                .withFlags(Intent.FLAG_NOT_OHOS_COMPONENT)
                .build();
        intent.setOperation(operation);
        BaseApplication.i().startAbility(intent, 0);
    }

}
